﻿using UnityEngine;
using System.Collections;

public class MuzzleScript : MonoBehaviour
{
		public Rigidbody2D fire;
		// Use this for initialization
		void Start ()
		{
	
		}
	
		// Update is called once per frame
		void Update ()
		{
				if (Controll.Instance.Shot) {
					
						StartCoroutine ("shoot");	
						
				}
		}
		IEnumerator shoot ()
		{
				for (int i=0; i<5; i++) {
						Rigidbody2D fire_ = Instantiate (fire, transform.position, Quaternion.identity) as Rigidbody2D; 
						fire_.velocity = new Vector2 (10, 0);
						yield return new WaitForSeconds (.1f);
				}
				
		}
}
